from fastapi import APIRouter,Request
from fastapi.templating import Jinja2Templates


app8 = APIRouter()

# 创建模板对象
templates = Jinja2Templates(directory="templates")

@app8.get("/index")
async def index(request: Request):
    # 这些数据是从数据库中查询出来的
    name = '刘千琪'
    age = 16
    gender = '女'

    students = ['刘千琪','赵俊','姚晓冲','任瑜阳']
    return templates.TemplateResponse('index.html',{
        'request': request,
        'name':name,
        'age':age,
        'gender':gender,
        'stus':students,
    })


